package com.jlastu.znb.view;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.jlastu.znb.R;

public class MyGoodsActivity extends AppCompatActivity {
    private ImageView mBack;
    private TextView mTextView1;
    private TextView mTextView2;
    private TextView mTextView3;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_goods);
        mTextView1 = findViewById(R.id.goods_title1);
        mTextView2 = findViewById(R.id.goods_title2);
        mTextView3 = findViewById(R.id.goods_title3);

        // 初始化时默认选中第一个标签
        setTabSelected(mTextView1);

        // 设置点击事件
        mTextView1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                setTabSelected(mTextView1);
            }
        });
        mTextView2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                setTabSelected(mTextView2);
            }
        });
        mTextView3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                setTabSelected(mTextView3);
            }
        });
        mBack = findViewById(R.id.back);
        mBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
    }
    private void setTabSelected(TextView selectedTab) {
        // 重置所有标签为未选中状态
        mTextView1.setSelected(false);
        mTextView2.setSelected(false);
        mTextView3.setSelected(false);

        // 将被点击的标签设置为选中状态
        selectedTab.setSelected(true);
    }
}
